import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:star_author/config/base_configuration.dart';

class PickerAction {
  static show(
    BuildContext context, {
    required List<Map<String, String>> data,
    void Function(Picker, List<int>)? onConfirm,
  }) {
    TextStyle buttonStyle = TextStyle(
      color: ColorConf.green,
      fontSize: 16,
      fontWeight: FontWeight.bold,
    );
    Picker(
      adapter: PickerDataAdapter(data: [
        for (Map<String, String> item in data)
          PickerItem(
            text: Center(
              child: Text(
                item['label']!,
                style: TextStyle(
                  color: ColorConf.gray,
                  fontSize: 18,
                ),
              ),
            ),
          )
      ]),
      cancelText: '取消',
      cancelTextStyle: buttonStyle,
      confirmText: '确定',
      confirmTextStyle: buttonStyle,
      height: 240,
      itemExtent: 60,
      onConfirm: onConfirm,
    )..showModal(context);
  }
}
